<?php
include("./api.inc.php");
require './config.php';
if($_POST['do'] == 'do'){
	$km = $_POST['km'];
	$ip = $_SERVER['REMOTE_ADDR'];
	$date = date("Y-m-d H-i-s");
	//$row=$DB->get_row("SELECT * FROM auth_kms WHERE km='{$km}' limit 1");
	$row2=$DB->get_row("SELECT * FROM auth_kms WHERE VisitorIp='{$ip}'");
	$row=$DB->get_row("SELECT * FROM auth_kms WHERE km = '{$km}'");
	if($km == '' or $ip ==''){
		exit("<script language='javascript'>alert('所有项不能留空!');history.go(-1);</script>");
	}
	if(!$row){
		exit("<script language='javascript'>alert('此卡密不存在!');history.go(-1);</script>");
	}else if($row['Expiration'] != NULL &&$row['Expiration'] < time()){
		exit("<script language='javascript'>alert('此卡密已失效！');history.go(-1);</script>");
	}
	
    if($row['type'] == 'ClassB_1')
	{
	$Expiration = time();
	}
	if($row['type'] == 'ClassB_30')
	{
	$Expiration = strtotime("+30 day");
	}
	if($row['type'] == 'ClassB_90')
	{
	$Expiration = strtotime("+90 day");
	}
	if($row['type'] == 'ClassB_365')
	{
	$Expiration = strtotime("+365 day");
	}
		$DB->query("UPDATE `auth_kms` SET `zt` = '已激活',`VisitorIp` = '".$_SERVER['REMOTE_ADDR']."',`Expiration` = '".$Expiration."', `activation` = '".time()."' WHERE `auth_kms`.`id` = ".$row['id'].";");
		exit("<script language='javascript'>alert('授权成功!');history.go(-1);</script>");
	}
?>
<!DOCTYPE html>
<head>
<meta name="baidu-site-verification" content="hE6VuDTDDZ" />
<meta name='zyiis_check_verify' content='8522ccc657813a5aa350dbc60e15ac37'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<meta name="format-detection" content="telephone=no">
<meta charset="UTF-8">
<meta name="description" content="Violate Responsive Admin Template">
<meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
<title>自助授权 - 正版授权系统</title>
<link href="static/css/music.css" rel="stylesheet">
<link href="static/css/bootstrap.min.css" rel="stylesheet">
<link href="static/css/animate.min.css" rel="stylesheet">
<link href="static/css/font-awesome.min.css" rel="stylesheet">
<link href="static/css/form.css" rel="stylesheet">
<link href="static/css/calendar.css" rel="stylesheet">
<link href="static/css/file-manager.css" rel="stylesheet">
<link href="static/css/style.css" rel="stylesheet">
<link href="static/css/icons.css" rel="stylesheet">
<link href="static/css/generics.css" rel="stylesheet">
<STYLE>.loginscreen.middle-box{width:300px;}.middle-box{max-width:400px;z-index:100;margin:0 auto;padding-top:100px;}</STYLE>
</head>
<body id="skin-blur-violate">
<section id="main">
<section class="middle-box " align="center">
<div class="tile p-15">
<div class="container">
<img id="btnAudio" class="profile-pic animated" src="http://q.qlogo.cn/headimg_dl?bs=qq&dst_uin=9379401&fid=blog&spec=100" alt="">
<form class="form-horizontal" method="post" action="">
<input type="hidden" name="do" value="do">
<div class="form-group">
<label for="exampleInputEmail1">自助授权</label>
<div class="panel-body">
<label for="exampleInputEmail1">卡密</label>
 <input type="text" name="km" class="form-control" placeholder="请输入卡密!">
 <!--<label for="exampleInputEmail1">IP</label>-->
 <!--<input type="text" name='ip' class="form-control" placeholder="请输入IP">-->
 <label for="exampleInputEmail1">IP</label>
<input type="text" name='ip' class="form-control" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" readonly>
<div class="form-group">
</label>
</div>
<div class="fileupload fileupload-new" data-provides="fileupload">
<button type="submit" class="btn btn-block btn-alt" >确认授权</button>
</div>
</form>
</div>
<script src="get/qrlogin.js"></script>
<script src="static/js/jquery.min.js"></script>  
<script src="static/js/jquery-ui.min.js"></script>  
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/scroll.min.js"></script>  
<script src="static/js/calendar.min.js"></script>  
<script src="static/js/feeds.min.js"></script>  
<script src="static/js/elfinder.min.js"></script>  
<script src="static/js/music.js"></script>
<script type="text/javascript">
            $(document).ready(function() {
                 $('#fileManager').elfinder({
                      resizable: false,
                      url : 'php/connector.minimal.php',  // connector URL (REQUIRED)
                      uiOptions : {
                      toolbar : [
                              ['back', 'forward', 'home', 'reload'],
                              ['mkdir', 'mkfile', 'upload'],
                              ['view', 'sort'],
                              ['search']
                      ]},
                      height: 500
                 });
                 
                 $('.elfinder-cwd-wrapper, .elfinder-navbar').niceScroll();
            });
</script>
</body>
</html>